<template>
    <view class="p_20">
        <view v-for="(item,index) in goodsListData" :key="index" >
            <view @click="handleToInfo(item)">
                <view class="dis_f_sb">
                    <view>
                        <view class="dis_f_l">
                            <view class="m_r_5">
                                <view>
                                    <u-tag text="招聘" v-if="item.type==1" plain size="mini" ></u-tag>
                                    <u-tag text="求职" v-else plain size="mini" type="warning"></u-tag>
                                </view>
                            </view>
                            <view class="over2" style="flex: 1"> {{item.bt}} </view>
                        </view>

                        <view class="c_9 m_t_10 m_b_10 f_s_14 over2">{{item.nr}}</view>
                    </view>
                    <u-image :src="item.photoUrl" width="200rpx" height="200rpx"></u-image>
                </view>
                <view class="dis_f_l_c m_b_20">
                    <u-icon name="map" ></u-icon>
                    <view class="m_l_5 c_9 f_s_12">{{item.province}}{{item.city}}{{item.districts}}{{item.locationsName||''}}</view>
                </view>
                <view v-if="isReject&&item.shly" class="c_red f_s_12 dis_f_r_c">
                    驳回理：{{item.shly}}
                </view>
            </view>
            <view class="dis_f_r_c" v-if="isLike">
                <u-icon v-if="item.sfxh" name="heart-fill" size="30" color="red" @click="handleLike(item)"></u-icon>
                <u-icon v-else name="heart" size="30"   @click="handleLike(item)"></u-icon>
            </view>
            <u-divider></u-divider>
        </view>
    </view>
</template>
<script>
export default {
    name: "index",
    props: {
        goodsList: {
            type: Array,
            default: []
        },
        isLike: {
            type: Boolean,
            default: false
        },
        isReject: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            goodsListData:this.goodsList||[],
        }
    },
    watch: {
        goodsList(curVal) {
            this.goodsListData=[]
            if (curVal.length>0){
                this.goodsListData = curVal
                for (let i = 0; i <curVal.length; i++) {
                    if (curVal[i].photoUrl){
                        this.goodsListData[i].photoUrl = curVal[i].photoUrl.split(',')[0]
                    }
                }
            }
        }
    },
    methods:{
        handleToInfo(item){
            uni.navigateTo({
                url: '/pages/index/info?goodsId='+item.id
            })
        },
        handleLike(item){
            this.$emit('handleLike',item)
        }
    }
}
</script>

<style scoped lang="scss">

</style>
